<!--
 * @Author: zjj
 * @Date: 2019-11-21 14:44:42
 * @LastEditors: zjj
 * @LastEditTime: 2019-11-22 10:03:45
 -->
<!--  -->
<template>
  <div class="recommand">
    <Nav title="推荐规则">
      <template v-slot:left>
        <span class="back" @click="$router.back()"></span>
      </template>
    </Nav>
    <div class="body-wrapper">
      <div class="body">
        <div class="product-wrap flex">
          <img class="product-img" :src="activityDetail.pid_reward.img" alt="">
          <div class="product-info">
            <div class="f-14">{{activityDetail.pid_reward.name}}</div>
            <div class="color-gray mt-14 f-12">{{activityDetail.pid_reward.tag_group}}</div>
            <div class="price">市场价：￥{{activityDetail.pid_reward.price}}</div>
          </div>
          <div class="share-tip">本期推广奖励</div>
        </div>
        <div class="share-now flex justify-center aligin-center" @click="shareNow">立即分享</div>
        <div class="share-count">已有{{activityDetail.share_num}}人分享</div>
        <div class="rule f-14 color-white">
          <div class="f-18">【推广奖励说明】</div>
          <div>1、通过分享本次活动，或者分享APP给好友，好友注册后，您会自动成为推荐人，推荐关系永久保留，一次推荐，永久受益。</div>
          <div>
            2、本次被推荐的好友中奖获得
            <span class="color-out">{{activityDetail.name}}</span>
            ，您将会获得推荐专属赠品
            <span class="color-out">{{activityDetail.pid_reward.name}}</span>
            一台。
          </div>
          <div>3、开奖后进入“个人中心-团队订单”，可查看您的好友是否中奖；您的专属赠品会显示在“个人中心-我的赠品”。</div>
          <div>4、您获得的赠品将会通过邮寄的方式寄给您，请关注“个人中心-我的赠品-赠品详情-物流信息”</div>
        </div>
      </div>
    </div>
    <div class="info" v-if="showMask">
      <div class="J-weixin-tip weixin-tip">
        <div class="weixin-tip-content">请在菜单中选择分享</div>
      </div>
      <div class="btn flex justify-center aligin-center" @click="showMask=false">我知道了</div>
    </div>
  </div>
</template>

<script>
import Nav from "../../components/Nav";
import {shareRule} from "../../api/api"
export default {
  components: { Nav },
  data() {
    return {
        showMask: false, //显示指引
        activityDetail:{pid_reward:{}}
    };
  },
  computed: {},
  watch: {},
  methods: {
      _shareConfig(jsk) {
      wx.config(jsk);
      wx.ready(() => {
        wx.updateTimelineShareData({
          title: this.activityDetail.name, // 分享标题
          link: window.location.origin+window.location.pathname + "?pid=" + this.activityDetail.uid, // 分享链接，该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
          imgUrl: this.activityDetail.content_image, // 分享图标
          success: function() {
            // 设置成功
          }
        });
        wx.updateAppMessageShareData({
          title: this.activityDetail.name, // 分享标题
          link: window.location.origin+window.location.pathname+ "?pid=" + this.activityDetail.uid, // 分享链接，该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
          desc: "兰溪官方特色购物平台。", // 分享描述
          imgUrl: this.activityDetail.content_image, // 分享图标
          success: function() {
            // 设置成功
          }
        });
      });
      wx.error(res => {
        // config信息验证失败会执行error函数，如签名过期导致验证失败，具体错误信息可以打开config的debug模式查看，也可以在返回的res参数中查看，对于SPA可以在这里更新签名。
      });
    },
    shareNow(){
      var ua = navigator.userAgent.toLowerCase();
      var isWeixin = ua.indexOf("micromessenger") != -1;
      if (isWeixin) {
        this.showMask = true;
      } else {
        this.$copyText(
          "https://www.weile9.com/detail/"+this.$route.params.id + "?pid=" + this.activityDetail.uid
        ).then(
          e => {
            this.$toast("复制成功！");
          },
          e => {
            this.$notify(e);
          }
        );
      }
    }
  },
  created() {},
  mounted() {
    shareRule({id:this.$route.params.id}).then(({data:{result}})=>{
      this.activityDetail=result
        // 分享
        if (typeof wx !="undefined") {
          this._shareConfig(result.jsk);
        }
    })
  },
  updated() {}, //生命周期 - 更新之后
  destroyed() {} //生命周期 - 销毁完成
};
</script>
<style lang='less' scoped>
//@import url(); 引入公共css类
.recommand {
  height: 100%;
  .body-wrapper {
    height: calc(100% - 45px);
    overflow: auto;
  }
  .body {
    padding-top: 220px;
    box-sizing: border-box;
    background: url("../../assets/imgs/winner-bg.png");
    background-size: 100% 100%;

    .product-wrap {
      position: relative;
      padding: 20px 0 9px 16px;
      margin: 0 auto;
      width: 313px;
      height: 159px;
      background: rgba(255, 255, 255, 1);
      box-shadow: 0px 0px 12px 0px rgba(75, 14, 169, 1);
      border-radius: 4px;
      .share-tip {
        position: absolute;
        left: 19px;
        top: -21px;
        padding: 7px 4px;
        font-size: 15px;
        color: #fff;
        background: linear-gradient(
          0deg,
          rgba(73, 10, 241, 1),
          rgba(159, 73, 254, 1)
        );
        border-radius: 5px;
      }
      .product-img {
        flex-shrink:0;
        width: 130px;
        height: 130px;
      }
      .product-info {
        margin-left: 10px;
        padding-top: 11px;
      }
      .price {
        margin-top: 46px;
        font-size: 14px;
        color: rgba(215, 9, 30, 1);
      }
    }
    .share-now {
      margin: 22px auto 0;
      width: 313px;
      height: 41px;
      font-size: 18px;
      color: #fff;
      background: rgba(255, 204, 1, 1);
      border-radius: 4px;
    }
    .share-count {
      margin: 12px 0 0 33px;
      font-size: 12px;
      color: rgba(255, 204, 1, 1);
    }
    .rule {
      padding-bottom: 20px;
      margin: 28px auto 0;
      width: 336px;
      line-height: 24px;
      .color-out {
        color: #ffcc01;
      }
    }
  }
   .info {
    position: fixed;
    top: 0;
    left: 0;
    height: 100%;
    width: 100%;
    background: rgba(0, 0, 0, 0.6);
  }
  .btn {
    color: #fff;
    margin: 10px auto;
    width: 70px;
    height: 25px;
    border-radius: 5px;
    border: 1px dashed #fff;
  }
  .weixin-tip-content {
    font-size: 16px;
    letter-spacing: 5px;
    font-weight: bold;
    line-height: 20px;
  }
  .weixin-tip {
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
    color: #fff;
    width: 265px;
    padding: 55px 0 0;
    margin: 0 auto;
    text-align: center;
    background: url()
      no-repeat right top;
    background-size: 45px 68px;
  }

  .weixin-tip-img {
    padding: 110px 0 0;
  }

  .weixin-tip-img::after {
    display: block;
    margin: 15px auto;
    content: " ";
    background-size: cover;
  }
}
</style>